package com.gujia.concurrency.example.aqs;

import java.util.concurrent.*;

public class FutureTaskExample {


    public static void main(String[] args) throws Exception {

        FutureTask<String> futureTask = new FutureTask<String>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                System.out.println("do someting in callable");
                Thread.sleep(5000);
                return "done";
            }
        });

        new Thread(futureTask).start();

        Thread.sleep(1000);

        String result = futureTask.get();

        System.out.println("result:"+result);
    }
}
